{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/json": "{\"LastUpdated\":\"2020-07-09T18:41:22.1664408-07:00\",\"IsCompleted\":true,\"Description\":\"Adding package Microsoft.Quantum.Numerics\",\"Subtask\":\"done\"}",
      "text/plain": [
       "Adding package Microsoft.Quantum.Numerics: done!"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/json": "[\"Microsoft.Quantum.Standard::0.12.20062906-beta\",\"Microsoft.Quantum.Numerics::0.12.20062906-beta\"]",
      "text/html": [
       "<ul><li>Microsoft.Quantum.Standard::0.12.20062906-beta</li><li>Microsoft.Quantum.Numerics::0.12.20062906-beta</li></ul>"
      ],
      "text/plain": [
       "Microsoft.Quantum.Standard::0.12.20062906-beta, Microsoft.Quantum.Numerics::0.12.20062906-beta"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%package Microsoft.Quantum.Numerics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/json": "[\"Microsoft.Quantum.Numerics.Samples.EvaluatePolynomial\",\"Microsoft.Quantum.Numerics.Samples.RunProgram\"]",
      "text/html": [
       "<ul><li>Microsoft.Quantum.Numerics.Samples.EvaluatePolynomial</li><li>Microsoft.Quantum.Numerics.Samples.RunProgram</li></ul>"
      ],
      "text/plain": [
       "Microsoft.Quantum.Numerics.Samples.EvaluatePolynomial, Microsoft.Quantum.Numerics.Samples.RunProgram"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%workspace reload"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/json": "[\"RunPolynomialEvaluation\"]",
      "text/html": [
       "<ul><li>RunPolynomialEvaluation</li></ul>"
      ],
      "text/plain": [
       "RunPolynomialEvaluation"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "open Microsoft.Quantum.Math;\n",
    "open Microsoft.Quantum.Arrays;\n",
    "open Microsoft.Quantum.Numerics.Samples;\n",
    "\n",
    "operation RunPolynomialEvaluation() : Double[] {\n",
    "    let evaluationPoints = [0.0];\n",
    "    let polynomialCoefficients = [\n",
    "        0.9992759725166501,\n",
    "        -0.16566707016968898,\n",
    "        0.007958079331694682,\n",
    "        -0.0001450780334861007\n",
    "    ];\n",
    "    let (odd, even) = (true, false);\n",
    "\n",
    "    let pointPos = 3;\n",
    "    let numBits = 32;\n",
    "    return EvaluatePolynomial(\n",
    "        polynomialCoefficients,\n",
    "        evaluationPoints, numBits, pointPos,\n",
    "        odd, even\n",
    "    );\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/json": "[{\"Metric\":\"CNOT\",\"Sum\":1188320.0,\"Max\":1188320.0},{\"Metric\":\"QubitClifford\",\"Sum\":208244.0,\"Max\":208244.0},{\"Metric\":\"R\",\"Sum\":0.0,\"Max\":0.0},{\"Metric\":\"Measure\",\"Sum\":96.0,\"Max\":96.0},{\"Metric\":\"T\",\"Sum\":727440.0,\"Max\":727440.0},{\"Metric\":\"Depth\",\"Sum\":406553.0,\"Max\":406553.0},{\"Metric\":\"Width\",\"Sum\":354.0,\"Max\":354.0},{\"Metric\":\"BorrowedWidth\",\"Sum\":0.0,\"Max\":0.0}]",
      "text/html": [
       "<table><thead><tr><th style=\"text-align: start;\">Metric</th><th style=\"text-align: start;\">Sum</th><th style=\"text-align: start;\">Max</th></tr></thead><tbody><tr><td style=\"text-align: start;\">CNOT</td><td style=\"text-align: start;\">1188320</td><td style=\"text-align: start;\">1188320</td></tr><tr><td style=\"text-align: start;\">QubitClifford</td><td style=\"text-align: start;\">208244</td><td style=\"text-align: start;\">208244</td></tr><tr><td style=\"text-align: start;\">R</td><td style=\"text-align: start;\">0</td><td style=\"text-align: start;\">0</td></tr><tr><td style=\"text-align: start;\">Measure</td><td style=\"text-align: start;\">96</td><td style=\"text-align: start;\">96</td></tr><tr><td style=\"text-align: start;\">T</td><td style=\"text-align: start;\">727440</td><td style=\"text-align: start;\">727440</td></tr><tr><td style=\"text-align: start;\">Depth</td><td style=\"text-align: start;\">406553</td><td style=\"text-align: start;\">406553</td></tr><tr><td style=\"text-align: start;\">Width</td><td style=\"text-align: start;\">354</td><td style=\"text-align: start;\">354</td></tr><tr><td style=\"text-align: start;\">BorrowedWidth</td><td style=\"text-align: start;\">0</td><td style=\"text-align: start;\">0</td></tr></tbody></table>"
      ],
      "text/plain": [
       "Metric        Sum     Max\r\n",
       "------------- ------- -------\r\n",
       "CNOT          1188320 1188320\r\n",
       "QubitClifford 208244  208244\r\n",
       "R             0       0\r\n",
       "Measure       96      96\r\n",
       "T             727440  727440\r\n",
       "Depth         406553  406553\r\n",
       "Width         354     354\r\n",
       "BorrowedWidth 0       0\r\n"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%estimate RunPolynomialEvaluation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Q#",
   "language": "qsharp",
   "name": "iqsharp"
  },
  "language_info": {
   "file_extension": ".qs",
   "mimetype": "text/x-qsharp",
   "name": "qsharp",
   "version": "0.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
